import {AxiosPromise} from "axios";
import request from "@/utils/request";
import {TenantFormData, TenantPageResult, TenantQueryParam} from "@/types/system/tenant";

/**
 * 获取租户分页列表
 *
 * @param queryParams
 */
export function listTenantPages(queryParams: TenantQueryParam): AxiosPromise<TenantPageResult> {
  return request({
    url: '/tenant/listByPage',
    method: 'get',
    params: queryParams,
  });
}


/**
 * 获取租户详情
 *
 * @param id
 */
export function getTenantDetail(id: string): AxiosPromise<TenantFormData> {
  return request({
    url: `/tenant/details/${id}`,
    method: 'get',
  });
}


/**
 * 新增租户
 */
export function addTenant(data: TenantFormData) {
  return request({
    url: '/tenant/add',
    method: 'post',
    data: data,
  });
}

/**
 * 修改租户
 */
export function updateTenant(id: string, data: TenantFormData) {
  return request({
    url: '/tenant/updateById/' + id,
    method: 'put',
    data: data,
  });
}

/**
 * 修改用户状态
 *
 * @param id
 * @param status
 */
export function updateTenantStatus(id: string, status: number) {
  return request({
    url: '/tenant/updateTenantStatus/' + id,
    method: 'put',
    params: {status: status},
  });
}


/**
 * 删除租户
 *
 * @param id
 */
export function deleteTenant(id: string) {
  return request({
    url: '/tenant/delete/' + id,
    method: 'delete',
  });
}
